package com.example.Opd_ISF_Android_Application.view.activities;

import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.*;

import android.os.Bundle;
import com.example.Opd_ISF_Android_Application.R;

import java.lang.Override;

/**
 * Created with IntelliJ IDEA.
 * User: Dell
 * Date: 26/03/13
 * Time: 12:09
 * To change this template use File | Settings | File Templates.
 */
public class MainActivity extends TabActivity {

    private static TabHost tabHost;
    private static TabHost.TabSpec postSpec;
    private static TabHost.TabSpec rankSpec;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);    //To change body of overridden methods use File | Settings | File Templates.
        setContentView(R.layout.main);

        // initialise components & list
        initialiseComponents();
    }

    private void initialiseComponents() {
        tabHost = getTabHost();

        //Rankings Tab
        View tabView = createTabView(this, "Rankings");
        rankSpec = tabHost.newTabSpec("Rankings");
        rankSpec.setIndicator(tabView);
        Intent rankingIntent = new Intent(this, FilterRankingsActivity.class);
        rankSpec.setContent(rankingIntent);

        //Post Score
        tabView = createTabView(this, "Post a score");
        postSpec = tabHost.newTabSpec("Post a score");
        postSpec.setIndicator(tabView);
        Intent postSpecIntent = new Intent(this, LoginActivity.class);
        postSpec.setContent(postSpecIntent);

        //Add tabs
        tabHost.addTab(rankSpec);
        tabHost.addTab(postSpec);

    }


    private static View createTabView(Context context, String tabText) {
        View view = LayoutInflater.from(context).inflate(R.layout.main_custom_tab, null, false);
        TextView tv = (TextView) view.findViewById(R.id.tabTitleText);
        tv.setText(tabText);
        return view;
    }


}
